#ifndef _OBJECT2D_H_
#define _OBJECT2D_H_

#include "engine.h"
#include "entity/entity3D.h"

namespace engine
{

    class Object2D
    {
    public:
        typedef std::shared_ptr<Object2D> ptr;

    public:
        Object2D()
            : Position(glm::vec3(0.0f, 0.0f, 0.0f)), Rotate(glm::vec3(0.0f, 0.0f, 0.0f)), Scale(glm::vec3(1.0f, 1.0f, 1.0f))
        {
        }
        ~Object2D() {}

        void addChildren(Object2D *object)
        {
            this->mChildren.push_back(object);
        }

        void setPosition(float x, float y)
        {
            this->Position.x = x;
            this->Position.y = y;
        }

        void setRotate(float z)
        {
            this->Rotate.z = z;
        }

        void setScale(float x, float y)
        {
            this->Scale.x = x;
            this->Scale.y = y;
        }

        glm::mat4 getTransformMatrix()
        {
            glm::mat4 trans = glm::mat3(1.0f); //单位阵
            trans = glm::translate(trans, glm::vec3(this->Position.x, this->Position.y, 0));
            trans = glm::rotate(trans, glm::radians(this->Rotate.z), glm::vec3(0.0, 0.0, 1.0)); //z
            trans = glm::scale(trans, glm::vec3(this->Scale.x, this->Scale.y, 0));
            return trans;
        }

    public:
        std::vector<Object2D *> mChildren;

    protected:
        glm::vec3 Position;
        glm::vec3 Rotate;
        glm::vec3 Scale;
    };

}
#endif